! set an expression to display this name and add "+" if there
! are ancestors
sub NameWithAncestors,#parent,#label,#nameWidth
  if #parent is validlink
    if @#parent.SEX="F"
      cell static,local("Mother")&":"
    else
      cell static,local("Father")&":"
    endif
    sizetofit
    set tabwidth -1 alignment right

    cell LinkButton
    RecordLink #parent
    TextExpression @#parent.NAME
    AppendedExpression altview
    if @#parent.FAMC!=""
      Format "%@"&#ANCArrow
    endif
    set font "Hyperlink Text"
    set border no alignment left width #nameWidth
    sizetofit -1
    if #nameWidth>0
      if #cellWidth$>#nameWidth
        set width #nameWidth
      endif
    endif
	! "Click to view Father's record" or "Mother's"
    #helpKey="Click to view "&#label&"'s record"
    help local(#helpKey)
  else
    cell static,local(#label)&":"
    sizetofit
    set tabwidth -1 alignment right

    cell static "<"&local("Unknown")&">"
    sizetofit
  endif

endsub

!----------- Begin Template ------------

if #parentTag$!="INDI"
  if tagexists is true
    newline
    cell static local("Family")&":"
    sizetofit
    set tabwidth -1 alignment right

    cell LinkButton
    RecordLink @contents
    TextExpression @contents.rec
    AppendedExpression view
    set font "Hyperlink Text" border no
	sizetofit -1
    help local("Click to view family record")

    if #msg="ADOP"
	  show ADOP
    else
      hideexcess
    endif

  else
    ! button to link to family
    hskip 2
    cell CreateLinkButton
    set border shadowlesssquare width 25 height 25
    set image "family"
	TextExpression @contents.rec
	Autoreload yes
    help local("Click to link to family record")
  endif


else

  if tagexists is true
    ClearTabs
    SetTab #famLabelEnd

    ! marriage button
    NewLine
    cell LinkButton
    RecordLink @contents
    set Autoreload yes TextExpression @contents.rec
    set image "family"
    set width 25 height 25 border shadowlesssquare
    help local("Click to view family record")

    #topX=#hpos$+#cellWidth$+#cellSkip
    #topY=#vpos$
    show PEDI
    show STAT "FAMC"
    MoveTo #topX,#topY

    ! Parents
    gosub NameWithAncestors,@contents.HUSB,"Father",#leftPedi-#famLabelEnd-2*#cellSkip
    newLine -1
    gosub NameWithAncestors,@contents.WIFE,"Mother",-1

    ! notes might be left
    ShowAll NOTE "label"

  else
    cell CreateLinkButton
    set border shadowlesssquare width 25 height 25
    set image "family"
	Autoreload yes
    help local("Click to link to family record")

  endif

endif


